#Boa:Frame:Frame1

import wx
import wx.grid
import consultasBD
import consultasBD
import utiles
from decimal import Decimal

ROJO = (255, 145, 145, 255)
VERDE = (145, 255, 145, 255)
AZUL = (145, 145, 255, 255)
BLANCO = (255, 255, 255, 255)
AMARILLO = (254, 248, 191, 255)

def create(parent):
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1BUTTON2, wxID_FRAME1BUTTON3, 
 wxID_FRAME1BUTTON4, wxID_FRAME1GRID1, wxID_FRAME1PANEL1, 
 wxID_FRAME1STATICTEXT1, wxID_FRAME1STATICTEXT2, wxID_FRAME1TEXTCTRL1, 
] = [wx.NewId() for _init_ctrls in range(10)]

class Frame1(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(370, 123), size=wx.Size(985, 488),
              style=wx.DEFAULT_FRAME_STYLE,
              title='Resumen de Cuenta Corriente')
        self.SetClientSize(wx.Size(977, 461))

        self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
              pos=wx.Point(0, 0), size=wx.Size(977, 461),
              style=wx.TAB_TRAVERSAL)

        self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
              label='Nro. de Cliente', name='staticText1', parent=self.panel1,
              pos=wx.Point(8, 8), size=wx.Size(72, 13), style=0)

        self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL1, name='textCtrl1',
              parent=self.panel1, pos=wx.Point(8, 24), size=wx.Size(72, 21),
              style=0, value='')

        self.staticText2 = wx.StaticText(id=wxID_FRAME1STATICTEXT2, label=' ',
              name='staticText2', parent=self.panel1, pos=wx.Point(168, 24),
              size=wx.Size(5, 19), style=0)
        self.staticText2.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, 'Tahoma'))

        self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='Buscar',
              name='button1', parent=self.panel1, pos=wx.Point(88, 22),
              size=wx.Size(75, 23), style=0)

        self.button2 = wx.Button(id=wxID_FRAME1BUTTON2, label='Limpiar',
              name='button2', parent=self.panel1, pos=wx.Point(736, 22),
              size=wx.Size(75, 23), style=0)

        self.button3 = wx.Button(id=wxID_FRAME1BUTTON3, label='Imprimir',
              name='button3', parent=self.panel1, pos=wx.Point(816, 22),
              size=wx.Size(75, 23), style=0)

        self.button4 = wx.Button(id=wxID_FRAME1BUTTON4, label='Salir',
              name='button4', parent=self.panel1, pos=wx.Point(896, 22),
              size=wx.Size(75, 23), style=0)
        self.button4.Bind(wx.EVT_BUTTON, self.OnSalir, id=wxID_FRAME1BUTTON4)

        self.grid1 = wx.grid.Grid(id=wxID_FRAME1GRID1, name='grid1',
              parent=self.panel1, pos=wx.Point(8, 56), size=wx.Size(960, 400),
              style=0)

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.crearGrilla()

    def OnSalir(self, event):
        self.Close()

    def autosizegrilla(self):
        for i in xrange(self.grid1.GetNumberCols()):
            self.grid1.AutoSizeColumn(i,True)
        self.grid1.Refresh()

    def crearGrilla(self):
        #Cod Art Prov,Cod Sussan,Descri,Cant,$ Costo,Subtotal,Iva,Total,PrecioVenta
        #0            1          2      3    4       5        6   7     8
        columnas =['Fecha','Nro.Doc','Monto',\
                   'Efectivo','Tarjeta','Cheque','cc1','cc2','cc3','Saldo','Observacion']
        self.grid1.CreateGrid(1,len(columnas))
        for i, col in enumerate(columnas): 
            self.grid1.SetColLabelValue(i, col)
        self.autosizegrilla()
        self.grid1.EnableEditing(False)
        self.grid1.SetSelectionMode(wx.grid.Grid.wxGridSelectRows)

